package com.wrx.server.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 公共返回对象
 */

@Data
@NoArgsConstructor
//@AllArgsConstructor
public class RespBean {
    private long code;
    private String message;
    private Object obj;
    private Object obj2;


    public static RespBean success(Object obj){
        return new RespBean(200,"success",obj);
    }
    /**
     * 成功返回结果（code,message,obj)
     * @param message
     * @return
     */
    public static RespBean success(String message){
        return new RespBean(200,message,null);
    }

    /**
     * 成功返回结果（code,message)
     * @param message
     * @param obj
     * @return
     */
    public static RespBean success(String message,Object obj){
        return new RespBean(200,message,obj);
    }

    public static RespBean success(String message,Object obj,Object obj2){
        return new RespBean(200,message,obj,obj2);
    }

    /**
     * 失败返回结果(code,message,obj)
     * @param message
     * @return
     */
    public static RespBean error(String message){
        return new RespBean(500,message,null);
    }

    /**
     * 失败返回结果(code,message)
     * @param message
     * @param obj
     * @return
     */
    public static RespBean error(String message,Object obj){
        return new RespBean(500,message,obj);
    }

    /**
     * 构造方法
     * @param code
     * @param message
     * @param obj
     */
    public RespBean(long code, String message, Object obj) {
        this.code = code;
        this.message = message;
        this.obj = obj;
    }

    /**
     * 构造方法
     * @param code
     * @param message
     */
    public RespBean(long code, String message) {
        this.code = code;
        this.message = message;
    }


    public long getCode() {
        return code;
    }

    public void setCode(long code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getObj() {
        return obj;
    }

    public void setObj(Object obj) {
        this.obj = obj;
    }

    public Object getObj2() {
        return obj2;
    }

    public void setObj2(Object obj2) {
        this.obj2 = obj2;
    }

    public RespBean(long code, String message, Object obj, Object obj2) {
        this.code = code;
        this.message = message;
        this.obj = obj;
        this.obj2 = obj2;
    }
}
